package com.xingchi.tornado.storage.core.converter;

import lombok.Data;
import lombok.Getter;
import org.apache.commons.io.IOUtils;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

/**
* 下载文件holder
*
* @author           xingchi
* @date             2024/5/5 14:18
*/
@Getter
public class DownloadFileHolder implements Closeable, Serializable {

    private final String fileName;
    private final String sha256;
    private final InputStream inputStream;

    public DownloadFileHolder(String fileName, String sha256, InputStream inputStream) {
        this.fileName = fileName;
        this.sha256 = sha256;
        this.inputStream = inputStream;
    }

    @Override
    public void close() throws IOException {
        IOUtils.closeQuietly(inputStream);
    }
}
